﻿namespace NuGetCop.MSBuild.Tasks
{
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Diagnostics;
    using System.Diagnostics.Contracts;
    
    internal sealed class NuGetPackageRepository : INuGetPackageRepository
    {
        [DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private readonly ReadOnlyCollection<INuGetPackageReference> packageReferencesReferences;

        public NuGetPackageRepository(IList<INuGetPackageReference> packagesReferences)
        {
            Contract.Requires(packagesReferences != null);

            this.packageReferencesReferences = new ReadOnlyCollection<INuGetPackageReference>(packagesReferences);
        }
        
        public ReadOnlyCollection<INuGetPackageReference> PackageReferences
        {
            [DebuggerStepThrough]
            get { return packageReferencesReferences; }
        }

        [ContractInvariantMethod]
        private void ObjectInvariant()
        {
            Contract.Invariant(packageReferencesReferences != null);
        }
    }
}